/**
 * Created by smallcoder on 2016/3/3.
 */
var Promise = require('promise');
var memberLogService = require('../shoot/service/MemberLogService');
var logger = require('log4js').getLogger('logFilter');

var logFilter = {};

logFilter.saveCommentLog = function (req,res,next) {
    var memberId = req.body.memberId;
    var articleId = req.body.articleId;

    if(!memberId){
        next();

    }else{
        memberLogService.saveLog(memberId,articleId,0).then(function () {

            next();
        },function(err){
            next();
        })
    }


}

logFilter.saveArticleLog = function (req,res,next) {
    var memberId = req.body.memberId;
    var myMemberId = req.body.myMemberId;
    var type = req.body.type;
    if(!myMemberId){
        next();
    }else{
        var logType = 1;
        if(type==3){
            logType = 2;
        }
        memberLogService.saveLog(myMemberId,memberId,logType).then(function () {

            next();
        },function(err){
            next();
        })
    }

}

module.exports = logFilter;